home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.awt;
-
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Frame;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.awt.Scrollbar;
- import java.awt.TextField;
- import java.util.BitSet;
- import java.util.Date;
- import java.util.Enumeration;
- import java.util.Vector;
- import symantec.itools.db.pro.RelationView;
- import symjava.sql.SQLException;
-
- public class Grid extends Panel {
- boolean autoRedraw;
- Panel toolbar;
- Panel bottomPanel;
- Vector toolbarComponents;
- TvEventHandler eventHandler;
- Matrix cells;
- Matrix colHeadings;
- Matrix cellAttributes;
- Matrix headingAttributes;
- int preferredRowCount;
- int[] splitters;
- boolean fillLastColumn;
- Scrollbar vsb;
- Scrollbar hsb;
- int cursor;
- long clickTime;
- int topRow;
- int leftCol;
- int dragColumn;
- int xDragLast;
- boolean isDragging;
- int headingHeight;
- int cellHeight;
- int clickMargin;
- int currentCursor;
- // $FF: renamed from: im java.awt.Image
- Image field_0;
- // $FF: renamed from: gg java.awt.Graphics
- Graphics field_1;
- int height;
- int width;
- int vsbPosition;
- int hsbPosition;
- long scrollbarTimer;
- DataSource dataSource;
- DataSource headingSource;
- DefaultDataSource rowHeadingSource;
- CellHints hints;
- TableCell currSelectedCell;
- TableCell currCaptureCell;
- TableCell defaultCell;
- boolean tabbed;
- int rowHeadingWidth;
- CellHints rowHeadingHints;
- boolean autoCreate;
- int rowHeadingLabelStyle;
- int firstNumber;
- TableCell headingCell;
- TableCell currHeadingCell;
- TableCell cornerCell;
- public static final int AUTONUMBER = 0;
- public static final int BLANK = 1;
- public static final int USER_DEFINED = 2;
- public static final Integer TABLE_CELL = new Integer(1);
- public static final Integer CORNER_CELL = new Integer(2);
- public static final Integer COLUMN_HEADING = new Integer(3);
- public static final Integer ROW_HEADING = new Integer(4);
- public static String appendRowLabel = "Append";
- public static String deleteRowLabel = "Delete";
- public static String insertRowLabel = "Insert";
- public static String gotoRowLabel = "Goto >>>";
- public static String saveLabel = "Save";
- public static String restartLabel = "Restart";
- public static String undoRowLabel = "Undo";
- public static String undeleteRowLabel = "Undelete";
- public static final int NEW_ROW = 0;
- public static final int CLEAN_ROW = 1;
- public static final int DELETED_ROW = 2;
- public static final int MODIFIED_ROW = 3;
- public static final int GOT_FOCUS = 1004;
- public static final int LOST_FOCUS = 1005;
- public static final int INSERT = 3;
- public static final int DELETE = 4;
- public static final int APPEND = 5;
- public static final int MASTER_CHANGE = 6;
- public static final int UNDELETE = 7;
- public static final int CELL_EVENT = 50;
- public static final int BUTTON_DOWN_EVENT = 50;
- public static final int BUTTON_UP_EVENT = 51;
- public static final int BUTTON_FLICKER_DOWN_EVENT = 52;
- public static final int BUTTON_FLICKER_UP_EVENT = 53;
- public static final int UNDO_CELL_EVENT = 54;
- public static final int GOT_CELL_FOCUS = 55;
- public static final int LOST_CELL_FOCUS = 56;
- public static final int CELL_CONTENT_CHANGE = 57;
- public static final int CELL_KEY_DOWN = 58;
- public static final int CELL_KEY_UP = 59;
- public static final int CELL_MOUSE_UP = 60;
- public static final int CELL_MOUSE_DOWN = 61;
- public static final int CELL_MOUSE_DRAG = 62;
- public static final int CELL_MOUSE_DOUBLE = 63;
- public static final long CLICKTHRESHOLD = 250L;
- public static final int LEFT = 0;
- public static final int CENTER = 1;
- public static final int RIGHT = 2;
- public static final int NO_LINE = 0;
- public static final int THIN_LINE = 1;
- public static final int THICK_LINE = 2;
- public static final int DASHED_LINE = 3;
- public static final int TOP = 0;
- public static final int BOTTOM = 2;
- static TableCell defaultHeadingCell_ = new ButtonCell();
- static boolean defaultsInitialized;
- Panel gotoPanel;
- TextField gotoTextField;
- Button gotoButton;
- int lastScrollValue;
- boolean scrollDown;
- // $FF: renamed from: sb java.awt.Scrollbar
- Scrollbar field_2;
- BitSet selected;
- Coordinate selectionBase;
- Coordinate selectionLimit;
- boolean selectionMade;
-
- static void initDefaults() {
- if (!defaultsInitialized) {
- defaultHeadingCell_.setCoordinates(new Coordinate(0, 0));
- defaultHeadingCell_.type(2);
- defaultsInitialized = true;
- }
-
- }
-
- public Grid() {
- this(3, Color.white);
- }
-
- public Grid(int cols) {
- this(cols, Color.white);
- }
-
- public Grid(long rows) {
- this(rows, 0);
- }
-
- public Grid(long rows, int cols) {
- this(cols, Color.white);
- this.preferredRowCount = (int)rows;
- }
-
- public Grid(int cols, Color bg) {
- this.autoRedraw = true;
- this.toolbarComponents = new Vector();
- this.cells = new Matrix();
- this.colHeadings = new Matrix();
- this.cellAttributes = new Matrix();
- this.headingAttributes = new Matrix();
- this.preferredRowCount = 10;
- this.leftCol = 1;
- this.dragColumn = -1;
- this.xDragLast = -1;
- this.clickMargin = 5;
- this.headingSource = new DefaultDataSource(this);
- this.rowHeadingWidth = 30;
- this.autoCreate = true;
- this.rowHeadingLabelStyle = 1;
- this.firstNumber = 1;
- this.selected = new BitSet();
- this.selectionMade = false;
- this.dataSource = new DefaultDataSource(this);
- this.assignDefaults();
- this.dataSource.setDefaultData();
- this.createColumns(cols);
- ((Component)this).setBackground(bg);
- }
-
- public Grid(RelationView relView) throws SQLException {
- this(relView, relView.getParentRelationView());
- }
-
- Grid(RelationView relView, RelationView masterView) throws SQLException {
- this.autoRedraw = true;
- this.toolbarComponents = new Vector();
- this.cells = new Matrix();
- this.colHeadings = new Matrix();
- this.cellAttributes = new Matrix();
- this.headingAttributes = new Matrix();
- this.preferredRowCount = 10;
- this.leftCol = 1;
- this.dragColumn = -1;
- this.xDragLast = -1;
- this.clickMargin = 5;
- this.headingSource = new DefaultDataSource(this);
- this.rowHeadingWidth = 30;
- this.autoCreate = true;
- this.rowHeadingLabelStyle = 1;
- this.firstNumber = 1;
- this.selected = new BitSet();
- this.selectionMade = false;
- DbaDataStore store = new DbaDataStore(relView, masterView);
- DbDataSource source = new DbDataSource(store, store, store);
- this.dataSource = source;
- this.dataSource.setDefaultData();
- this.assignDefaults();
- this.dataSource.setGrid(this);
- if (this.dataSource.supportsMeta()) {
- try {
- this.dataSource.setupGrid(this);
- } catch (Exception e) {
- ((Throwable)e).printStackTrace();
- }
- }
-
- this.installDefaultEventHandler();
- this.forceRedraw(true);
- }
-
- public Grid(DataSource ds) {
- this.autoRedraw = true;
- this.toolbarComponents = new Vector();
- this.cells = new Matrix();
- this.colHeadings = new Matrix();
- this.cellAttributes = new Matrix();
- this.headingAttributes = new Matrix();
- this.preferredRowCount = 10;
- this.leftCol = 1;
- this.dragColumn = -1;
- this.xDragLast = -1;
- this.clickMargin = 5;
- this.headingSource = new DefaultDataSource(this);
- this.rowHeadingWidth = 30;
- this.autoCreate = true;
- this.rowHeadingLabelStyle = 1;
- this.firstNumber = 1;
- this.selected = new BitSet();
- this.selectionMade = false;
- this.dataSource = ds;
- this.dataSource.setDefaultData();
- this.assignDefaults();
- this.dataSource.setGrid(this);
- if (this.dataSource.supportsMeta()) {
- try {
- this.dataSource.setupGrid(this);
- } catch (Exception e) {
- ((Throwable)e).printStackTrace();
- }
- }
- }
-
- void assignDefaults() {
- initDefaults();
- ((Container)this).setLayout(new BorderLayout());
- ((Component)this).setFont(CellHints.stdFont);
- ((Component)this).setBackground(Color.white);
- ((Component)this).setForeground(Color.black);
- this.vsb = new Scrollbar(1);
- this.vsb.hide();
- this.toolbar = new Panel();
- this.toolbar.setLayout(new FlowLayout(0, 0, 0));
- this.toolbar.setBackground(Color.lightGray);
- this.hsb = new Scrollbar(0);
- Canvas pad = new Canvas();
- ((Component)pad).resize(this.vsb.preferredSize().width, this.hsb.preferredSize().height);
- this.bottomPanel = new Panel();
- this.bottomPanel.setBackground(Color.lightGray);
- this.bottomPanel.setLayout(new BorderLayout());
- this.bottomPanel.add("West", this.toolbar);
- Panel padding = new Panel();
- ((Container)padding).setLayout(new BorderLayout());
- ((Container)padding).add("North", this.hsb);
- this.bottomPanel.add("Center", padding);
- this.bottomPanel.add("East", pad);
- ((Container)this).add("East", this.vsb);
- ((Container)this).add("South", this.bottomPanel);
- this.hints = new CellHints(this);
- this.defaultCell = new BasicCell(this, this.dataSource);
- this.defaultCell.setCoordinates(new Coordinate(0, 0));
- this.defaultCell.setDefaultFlag();
- this.headingHeight = ((Component)this).getFontMetrics(CellHints.stdFont).getHeight() + 4;
- this.cellHeight = this.headingHeight;
- this.rowHeadingSource = new DefaultDataSource(this, true);
- this.rowHeadingHints = new CellHints(this);
- this.setCornerCell(defaultHeadingCell_);
- this.setDefaultRowHeadingCell(defaultHeadingCell_);
-
- try {
- this.rowHeadingSource.setData(0, 1, new ImageStringData(this.dataSource, ""));
- this.rowHeadingSource.setDefaultData(new ImageStringData(this.dataSource));
- } catch (TypeNotSupported var3) {
- }
- }
-
- public void setAutoRedraw(boolean redraw) {
- this.autoRedraw = redraw;
- }
-
- public boolean getAutoRedraw() {
- return this.autoRedraw;
- }
-
- public void installDefaultEventHandler() {
- this.installEventHandler(new DefaultTvEventHandler());
- }
-
- public void installEventHandler(TvEventHandler h) {
- this.eventHandler = h;
- this.eventHandler.setupView(this);
- }
-
- public DataSource getDataSource() {
- return this.dataSource;
- }
-
- public void addAppendButton() {
- this.addToolbarButton(appendRowLabel);
- }
-
- public void addAppendButton(String label) {
- this.removeAppendButton();
- appendRowLabel = label;
- this.addToolbarButton(label);
- }
-
- public void removeAppendButton() {
- this.removeToolbarButton(appendRowLabel);
- }
-
- public void addInsertButton() {
- this.addToolbarButton(insertRowLabel);
- }
-
- public void addInsertButton(String label) {
- this.removeInsertButton();
- insertRowLabel = label;
- this.addToolbarButton(label);
- }
-
- public void removeInsertButton() {
- this.removeToolbarButton(insertRowLabel);
- }
-
- public void addDeleteButton() {
- this.addToolbarButton(deleteRowLabel);
- }
-
- public void addDeleteButton(String label) {
- this.removeDeleteButton();
- deleteRowLabel = label;
- this.addToolbarButton(label);
- }
-
- public void removeDeleteButton() {
- this.removeToolbarButton(deleteRowLabel);
- }
-
- public void addSaveButton() {
- this.addToolbarButton(saveLabel);
- }
-
- public void addSaveButton(String label) {
- this.removeSaveButton();
- saveLabel = label;
- this.addToolbarButton(label);
- }
-
- public void removeSaveButton() {
- this.removeToolbarButton(saveLabel);
- }
-
- public void addRestartButton() {
- this.addToolbarButton(restartLabel);
- }
-
- public void addRestartButton(String label) {
- this.removeRestartButton();
- restartLabel = label;
- this.addToolbarButton(label);
- }
-
- public void removeRestartButton() {
- this.removeToolbarButton(restartLabel);
- }
-
- public void addUndeleteButton() {
- this.addToolbarButton(undeleteRowLabel);
- }
-
- public void addUndeleteButton(String label) {
- this.removeUndeleteButton();
- undeleteRowLabel = label;
- this.addToolbarButton(label);
- }
-
- public void removeUndeleteButton() {
- this.removeToolbarButton(undeleteRowLabel);
- }
-
- public void addUndoButton() {
- this.addToolbarButton(undoRowLabel);
- }
-
- public void addUndoButton(String label) {
- this.removeUndoButton();
- undoRowLabel = label;
- this.addToolbarButton(label);
- }
-
- public void removeUndoButton() {
- this.removeToolbarButton(undoRowLabel);
- }
-
- public void addGotoButton() {
- if (this.gotoPanel == null) {
- this.gotoPanel = new Panel();
- this.gotoPanel.setLayout(new FlowLayout(0, 5, 0));
- this.gotoPanel.add(this.gotoButton = new Button(gotoRowLabel));
- this.gotoPanel.add(this.gotoTextField = new TextField(4));
- this.addToToolbar(this.gotoPanel);
- }
- }
-
- public void removeGotoButton() {
- if (this.gotoPanel != null) {
- this.removeFromToolbar(this.gotoPanel);
- this.gotoPanel = null;
- }
- }
-
- public void addToolbarButton(String label) {
- Enumeration e = this.toolbarComponents.elements();
-
- while(e.hasMoreElements()) {
- Component c = (Component)e.nextElement();
- if (c instanceof Button && ((Button)c).getLabel().equals(label)) {
- return;
- }
- }
-
- this.addToToolbar(new Button(label));
- }
-
- public void removeToolbarButton(String label) {
- Enumeration e = this.toolbarComponents.elements();
-
- while(e.hasMoreElements()) {
- Component c = (Component)e.nextElement();
- if (c instanceof Button && ((Button)c).getLabel().equals(label)) {
- this.toolbarComponents.removeElement(c);
- return;
- }
- }
-
- }
-
- public boolean isToolbarComponent(Object c) {
- return this.toolbarComponents.contains(c) || c == this.gotoTextField || c == this.gotoButton;
- }
-
- public void addToToolbar(Component c) {
- this.toolbarComponents.addElement(c);
- this.toolbar.add(c);
- }
-
- public void removeFromToolbar(Component c) {
- this.toolbarComponents.removeElement(c);
- this.toolbar.remove(c);
- }
-
- public void setFillLastColumn(boolean fill) {
- this.fillLastColumn = fill;
- }
-
- public boolean getFillLastColumn() {
- return this.fillLastColumn;
- }
-
- public synchronized void setHeading(String h, int col, int chars) {
- ButtonCell cell = new ButtonCell(1, col);
- cell.type(1);
- cell.setGrid(this, this.headingSource);
- this.colHeadings.updateElement(0, col - 1, cell);
-
- try {
- this.headingSource.setData(cell.getCoordinates(), new ImageStringData(this.dataSource, h));
- } catch (TypeNotSupported var5) {
- }
-
- this.setHeadingSize(col, chars);
- this.redraw();
- }
-
- public synchronized void setHeadingSize(int col, int chars) {
- CellHints hints = this.getHeadingHints(0, col);
- int width = ((Component)this).getFontMetrics(hints.font).charWidth('W') * chars;
- this.resizeColumn(col, this.splitters[col - 1] + width);
- }
-
- public Dimension preferredSize() {
- int w = 0;
- int h = 0;
- w = this.splitters[this.splitters.length - 1];
- h = (this.preferredRowCount + 1) * this.cellHeight;
- return new Dimension(w, h);
- }
-
- public Dimension minimumSize() {
- return this.preferredSize();
- }
-
- public synchronized void createColumns(int i) {
- this.cellAttributes.removeAllElements();
- this.headingAttributes.removeAllElements();
- this.headingAttributes.addElement(0, 0, new CellHints(this));
-
- for(int col = 1; col <= i; ++col) {
- this.cellAttributes.addElement(0, col, new CellHints(this));
- this.headingAttributes.addElement(0, col, new CellHints(this));
- }
-
- this.splitters = new int[i + 1];
- }
-
- public synchronized void setCornerCell(TableCell c) {
- this.cornerCell = c.cloneCell();
- this.cornerCell.setGrid(this, this.rowHeadingSource);
- this.cornerCell.setCoordinates(new Coordinate(0, 1));
- this.cornerCell.type(3);
- }
-
- public synchronized void setDefaultRowHeadingCell(TableCell c) {
- this.headingCell = c.cloneCell();
- this.headingCell.setGrid(this, this.rowHeadingSource);
- }
-
- public synchronized void setRowHeadingWidth(int w) {
- this.rowHeadingWidth = w;
- }
-
- public synchronized int getRowHeadingWidth(int w) {
- return this.rowHeadingWidth;
- }
-
- public void useRowHeadings(boolean use) {
- this.rowHeadingHints.visible = use;
- }
-
- public boolean isUsingRowHeadings() {
- return this.rowHeadingHints.visible;
- }
-
- public synchronized void setRowLabelHeadingStyle(int s) {
- if (s >= 0 && s <= 2) {
- this.rowHeadingLabelStyle = s;
- if (s == 0) {
- this.rowHeadingSource.doAutoNumbering(true);
- }
-
- } else {
- throw new IllegalArgumentException("Illegal heading label style");
- }
- }
-
- public synchronized void setRowHeadingAlignment(int a) {
- if (a >= 0 && a <= 2) {
- this.rowHeadingHints.align = a;
- } else {
- throw new IllegalArgumentException("Illegal alignment style");
- }
- }
-
- public int getRowHeadingAlignment() {
- return this.rowHeadingHints.align;
- }
-
- public int getRowLabelHeadingStyle() {
- return this.rowHeadingLabelStyle;
- }
-
- public int getFirstAutoNumber() {
- return this.rowHeadingWidth;
- }
-
- public void setupAutonumbering(int first) {
- this.setupAutonumbering(first, this.rowHeadingWidth);
- }
-
- public synchronized void setupAutonumbering(int first, int pixels) {
- this.rowHeadingLabelStyle = 0;
- this.rowHeadingSource.doAutoNumbering(true, first);
- this.rowHeadingHints.visible = true;
- this.rowHeadingWidth = pixels;
- }
-
- public synchronized void setDefaultRowData(String s) {
- this.rowHeadingSource.setDefaultData(new ImageStringData(this.dataSource, s));
- }
-
- public synchronized void setDefaultRowData(Data d) {
- this.rowHeadingSource.setDefaultData(d);
- }
-
- public String getHeading(int col) {
- return this.cells.elementAt(-1, col).toString();
- }
-
- public synchronized void setHeadingFont(Font f, int col) {
- CellHints hints = this.getHeadingHints(0, col);
- hints.font = f;
- this.headingHeight = ((Component)this).getFontMetrics(f).getHeight();
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public Font getHeadingFont(int col) {
- return this.getHeadingHints(0, col).font();
- }
-
- public TableCell getCurrentCell() {
- return this.currSelectedCell;
- }
-
- public Data getCurrentCellData() throws DataNotAvailable {
- return this.currSelectedCell == null ? null : this.dataSource.getData(this.currSelectedCell.getCoordinates());
- }
-
- public Coordinate getCurrentCellCoordinates() {
- if (this.currSelectedCell == null) {
- return null;
- } else {
- Coordinate c = this.currSelectedCell.getCoordinates();
- return new Coordinate(c.row() + 1, c.col() + 1);
- }
- }
-
- public synchronized void setCurrentCell(int row, int col) {
- --row;
- --col;
- TableCell newSelection = null;
- if (this.currSelectedCell == null || row != this.currSelectedCell.row() || col != this.currSelectedCell.col()) {
- if (!this.cells.contains(row, col)) {
- if (row < 0 || !this.validRow(row) || col < 0 || col >= this.getNumberOfCols()) {
- return;
- }
-
- newSelection = this.getUniqueCell(row, col);
- } else {
- newSelection = (TableCell)this.cells.elementAt(row, col);
- }
-
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- }
-
- }
-
- public synchronized void setColBgColor(int col, Color bg) {
- CellHints h = this.getColHints(col - 1);
- h.bg = bg;
- }
-
- public synchronized void setColFgColor(int col, Color fg) {
- CellHints h = this.getColHints(col - 1);
- h.fg = fg;
- }
-
- public synchronized void setColFont(Font f, int col) {
- CellHints h = this.getColHints(col);
- h.font = f;
- this.cellHeight = ((Component)this).getFontMetrics(f).getHeight() + 4;
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public Font getColFont(int col) {
- --col;
- return this.getColHints(col).font();
- }
-
- public synchronized void setColEditable(int col, boolean edit) {
- CellHints h = this.getColHints(col - 1);
- h.editable = edit;
- }
-
- public boolean getColEditable(int col) {
- --col;
- return this.getColHints(col).editable();
- }
-
- public synchronized void setHeadingEditable(int col, boolean edit) {
- CellHints h = this.getHeadingHints(0, col);
- h.editable = edit;
- }
-
- public boolean getHeadingEditable(int col) {
- return this.getHeadingHints(0, col).editable();
- }
-
- public synchronized void setHeadingColors(int col, Color fg, Color bg) {
- CellHints h = this.getHeadingHints(0, col);
- h.fg = fg;
- h.bg = bg;
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public Color getHeadingFg(int col) {
- CellHints h = this.getHeadingHints(0, col);
- return h.fg;
- }
-
- public Color getHeadingBg(int col) {
- CellHints h = this.getHeadingHints(0, col);
- return h.bg;
- }
-
- public int getColumnSize(int i) {
- return this.getColumnWidth(i - 1);
- }
-
- public synchronized void setColumnAlignment(int col, int align) {
- CellHints h = this.getColHints(col - 1);
- h.align = align;
- h = this.getHeadingHints(0, col);
- h.align = align;
- }
-
- public int getNumberOfCols() {
- return this.splitters.length - 1;
- }
-
- public void setTopRow() {
- this.setTopRow(-1);
- }
-
- public synchronized void setTopRow(int row) {
- if (row >= 1) {
- this.topRow = row - 1;
- }
-
- try {
- this.dataSource.validDataRowRange(0, this.topRow + 1);
- } catch (DataNotAvailable var2) {
- if (this.topRow > this.cells.rows() - 1) {
- this.topRow = 0;
- }
- }
- }
-
- public int getNumberOfVisibleRows() {
- this.setTopRow();
- int count = (this.height - 3) / this.cellHeight - 1;
-
- try {
- int dataRows = this.dataSource.validDataRowRange(this.topRow, this.topRow + count);
- int lastCellRow = this.cells.rows();
- count = Math.min(count, Math.max(dataRows, lastCellRow) - this.topRow + 1);
- } catch (DataNotAvailable var4) {
- if (count > this.cells.rows()) {
- count = this.cells.rows() - this.topRow;
- }
- }
-
- return count;
- }
-
- public int getTopRow() {
- return this.topRow;
- }
-
- public void setCapture() {
- if (this.rowHeadingCell(this.currCaptureCell) && this.currSelectedCell != this.currCaptureCell) {
- this.currHeadingCell = null;
- }
-
- this.currCaptureCell = this.currSelectedCell;
- }
-
- public void setCapture(TableCell c) {
- if (this.rowHeadingCell(this.currCaptureCell) && c != this.currCaptureCell) {
- this.currHeadingCell = null;
- }
-
- this.currCaptureCell = c;
- }
-
- public void lostCapture() {
- if (this.rowHeadingCell(this.currCaptureCell)) {
- this.currHeadingCell = null;
- }
-
- this.currCaptureCell = null;
- }
-
- public boolean cellHasCapture() {
- return this.currCaptureCell != null;
- }
-
- public synchronized void clear() {
- this.clearAllSelections();
- this.cells.removeAllElements();
- this.dataSource.clear();
- this.xDragLast = -1;
- this.isDragging = false;
- this.topRow = 0;
- this.leftCol = 1;
- this.vsb.setValue(0);
- this.hsb.setValue(0);
- this.currSelectedCell = this.currCaptureCell = null;
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public synchronized void addCell(TableCell cell, String s) throws TypeNotSupported {
- cell = cell.cloneCell();
- cell.setGrid(this, this.dataSource);
- this.cells.updateElement(cell.row(), cell.col(), cell);
- this.dataSource.setData(cell.getCoordinates(), new ImageStringData(this.dataSource, s));
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public synchronized void addTextCell(int r, int c, String s) throws TypeNotSupported {
- --r;
- --c;
- this.dataSource.setData(r, c, new ImageStringData(this.dataSource, s));
- this.redraw();
- }
-
- public synchronized void addImageCell(int r, int c, Image i) throws TypeNotSupported {
- --r;
- --c;
- this.dataSource.setData(r, c, new ImageStringData(this.dataSource, i));
- this.redraw();
- }
-
- public synchronized void addCell(int r, int c, String s, Image i) throws TypeNotSupported {
- --r;
- --c;
- this.dataSource.setData(r, c, new ImageStringData(this.dataSource, s, i));
- this.redraw();
- }
-
- public String getCellText(int r, int c) throws DataNotAvailable {
- --r;
- --c;
- return this.dataSource.getData(r, c).toString();
- }
-
- public Data getCellData(int r, int c) throws DataNotAvailable {
- --r;
- --c;
- return this.dataSource.getData(r, c);
- }
-
- public FontMetrics getCellFontMetrics(TableCell c) {
- Font f = this.getCellFont(c);
- return ((Component)this).getFontMetrics(f);
- }
-
- public void update(Graphics g) {
- this.paint(g);
- }
-
- void checkClipping(Graphics g) {
- Rectangle r = g.getClipRect();
- Dimension d = ((Component)this).size();
- if (r.x != 0 || r.y != 0 || r.width != d.width || r.height != d.height) {
- ((Component)this).repaint();
- }
-
- }
-
- public void paint(Graphics g) {
- this.checkClipping(g);
- if (this.width != ((Component)this).size().width || this.height != ((Component)this).size().height) {
- this.redraw(true);
- }
-
- if (this.field_0 != null) {
- g.drawImage(this.field_0, 0, 0, this);
- }
- }
-
- public void addNotify() {
- super.addNotify();
- ((Component)this).repaint();
- }
-
- public int numRows() {
- return this.cells.rows();
- }
-
- void showScrollbars() {
- Dimension d = ((Component)this).size();
- Dimension actualViewSize = new Dimension();
- Dimension reqdViewSize = new Dimension();
- Dimension hsbSize = this.bottomPanel.preferredSize();
- Dimension vsbSize = this.vsb.preferredSize();
- boolean changed = false;
- boolean showVsb = false;
- int reqdHeight = this.cells.rows();
-
- try {
- this.dataSource.validDataRowRange(0, this.getPageSize().height + 2 + this.topRow);
- reqdHeight = Math.max(reqdHeight, this.dataSource.rows());
- } catch (DataNotAvailable var13) {
- }
-
- actualViewSize.height = this.height - this.headingHeight - 3 - this.bottomPanel.size().height;
- actualViewSize.width = d.width;
- reqdViewSize.height = reqdHeight * this.cellHeight;
- reqdViewSize.width = this.splitters[this.splitters.length - 1] + this.rowHeadingWidth;
- if (reqdViewSize.width > actualViewSize.width) {
- actualViewSize.height -= hsbSize.height;
- } else if (reqdViewSize.width > actualViewSize.width - vsbSize.width && reqdViewSize.height > actualViewSize.height - hsbSize.height) {
- actualViewSize.height -= hsbSize.height;
- }
-
- if (reqdViewSize.height > actualViewSize.height) {
- this.vsb.setValues(this.vsbPosition, 1, 0, reqdHeight - 1);
- this.vsb.setPageIncrement(this.getPageSize().height);
- this.vsb.show();
- showVsb = true;
- changed = true;
- actualViewSize.width -= vsbSize.width;
- } else {
- this.topRow = 0;
- this.vsb.hide();
- showVsb = false;
- }
-
- if (reqdViewSize.width > actualViewSize.width) {
- int i = 1;
- int row = 0;
- int col = 0;
- if (this.currSelectedCell != null) {
- Coordinate c = this.currSelectedCell.getCoordinates();
- row = c.row;
- col = c.col;
- }
-
- for(int shiftLeft = this.splitters[this.leftCol - 1] + this.rowHeadingWidth; i < this.splitters.length && this.splitters[i] - shiftLeft <= actualViewSize.width; ++i) {
- }
-
- this.hsb.setValues(this.hsbPosition, i, 1, this.splitters.length - 1);
- this.hsb.setPageIncrement(1);
- this.hsb.show();
- changed = true;
- } else {
- this.leftCol = 1;
- this.hsb.hide();
- }
-
- if (changed) {
- ((Component)this).getParent().paintAll(((Component)this).getParent().getGraphics());
- }
-
- }
-
- public void show() {
- this.redraw(true);
- }
-
- public int getColumnWidth(int col) {
- if (this.fillLastColumn && col == this.getNumberOfCols() - 1) {
- int var10001 = this.splitters[col];
- return ((Component)this).size().width - var10001 + 1;
- } else {
- return this.splitters[col + 1] - this.splitters[col];
- }
- }
-
- boolean rowHeadingCell(TableCell cell) {
- return cell != null && (cell == this.headingCell || cell == this.currHeadingCell || cell.type() == 2);
- }
-
- public Rectangle getCellBounds(TableCell cell) {
- return this.getCellBounds((TableCell)cell, (Rectangle)null);
- }
-
- public Rectangle getCellBounds(TableCell cell, Rectangle b) {
- Coordinate p = cell.getCoordinates();
- if (cell == this.cornerCell) {
- return new Rectangle(0, 0, this.rowHeadingWidth + 1, this.headingHeight + 2);
- } else if (this.rowHeadingCell(cell)) {
- return this.getRowHeadingBounds(cell, b);
- } else {
- return cell.type() == 1 ? this.getHeadingCellBounds(p, b) : this.getCellBounds(p, b);
- }
- }
-
- private Rectangle getCellBounds(Coordinate c, Rectangle b) {
- int shiftLeft = this.splitters[this.leftCol - 1];
- int row = c.row;
- int col = c.col;
- int w = this.getColumnWidth(col);
- int left = this.splitters[col] - shiftLeft - 1 + this.rowHeadingWidth;
- if (this.leftCol - 1 == col) {
- ++left;
- } else {
- ++w;
- }
-
- if (b == null) {
- b = new Rectangle();
- }
-
- b.reshape(left, (row - this.topRow) * this.cellHeight + this.headingHeight + 2, w, this.cellHeight + 1);
- return b;
- }
-
- public Rectangle getHeadingCellBounds(Coordinate coords, Rectangle b) {
- int shiftLeft = this.splitters[this.leftCol - 1];
- int col = coords.col;
- int w = this.getColumnWidth(col);
- int left = this.splitters[col] - shiftLeft - 1 + this.rowHeadingWidth;
- if (col == 0) {
- ++left;
- } else {
- ++w;
- }
-
- if (b == null) {
- b = new Rectangle();
- }
-
- b.reshape(left, 0, w, this.headingHeight + 2);
- return b;
- }
-
- public Rectangle getRowHeadingBounds(TableCell cell, Rectangle b) {
- b = this.getCellBounds(cell.getCoordinates(), b);
- b.x = 0;
- b.width = this.rowHeadingWidth + 1;
- return b;
- }
-
- public void redrawCell(TableCell c) {
- if (c != this.cornerCell && c.type() == 1) {
- Coordinate coord = c.getCoordinates();
- this.makeCellVisible(coord.row, coord.col);
- }
-
- this.hints.setHints(c);
- this.field_1.setColor(((Component)this).getBackground());
- Rectangle r = this.hints.bounds();
- this.field_1.fillRect(r.x, r.y, r.width - 1, r.height - 1);
- this.field_1.setColor(((Component)this).getForeground());
- c.drawCell(this.field_1, this.hints);
- if (c == this.currSelectedCell && c.isCellTypeEditable()) {
- this.frameCurrentCells();
- }
-
- ((Component)this).repaint();
- }
-
- protected void redrawCell(int row, int col) {
- if (this.validRow(row)) {
- if (col <= -1 || this.validCol(col)) {
- if (col == -1 && this.validRow(row)) {
- this.redrawRowHeadingCell(row);
- } else if (col != -1 || row != -1) {
- TableCell c = this.getUniqueCell(row, col);
- this.redrawCell(c);
- this.drawTableBoundary();
- }
- }
- }
- }
-
- public void redrawRow(int row) {
- --row;
- if (this.validRow(row)) {
- int cols = this.getNumberOfCols();
-
- for(int col = 0; col < cols; ++col) {
- this.redrawCell(row, col);
- }
-
- this.redrawRowHeadingCell(row);
- }
- }
-
- public void redrawAroundCell(TableCell c) {
- int row = c.row() - 1;
- int col = c.col() - 1;
-
- for(int i = 0; i <= 2; ++i) {
- for(int j = 0; j <= 2; ++j) {
- if (row + i < this.topRow) {
- if (col + j < this.leftCol - 1) {
- this.redrawCornerCell();
- }
-
- this.redrawColHeadingCell(col + j);
- } else {
- this.redrawCell(row + i, col + j);
- }
- }
- }
-
- }
-
- public Rectangle getTableBounds(Rectangle r) {
- Dimension d = ((Component)this).size();
- r.reshape(0, 0, d.width, d.height);
- if (this.vsb.isVisible()) {
- r.width -= this.vsb.size().width;
- }
-
- r.height -= this.bottomPanel.size().height;
- r.width = this.splitters[this.splitters.length - 1] - this.splitters[this.leftCol - 1] + 1;
- if (this.rowHeadingHints.visible) {
- r.width += this.rowHeadingWidth;
- }
-
- int visRows = (r.height - 2) / this.cellHeight;
- if (visRows + this.topRow > this.dataSource.rows()) {
- r.height = this.headingHeight + 2 + this.cellHeight * (this.dataSource.rows() - this.topRow) + 2;
- }
-
- return r;
- }
-
- protected void drawTableBoundary() {
- Dimension d = ((Component)this).size();
- Rectangle r = new Rectangle(0, 0, d.width, d.height);
- if (this.vsb.isVisible()) {
- r.width -= this.vsb.size().width;
- }
-
- r.height -= this.bottomPanel.size().height;
- this.field_1.setColor(Color.black);
- this.field_1.drawRect(r.x, r.y, r.width - 1, r.height - 1);
- r.width = this.splitters[this.splitters.length - 1] - this.splitters[this.leftCol - 1] + 1;
- if (this.rowHeadingHints.visible) {
- r.width += this.rowHeadingWidth;
- }
-
- int visRows = (r.height - 2) / this.cellHeight;
- if (visRows + this.topRow > this.dataSource.rows()) {
- r.height = this.headingHeight + 2 + this.cellHeight * (this.dataSource.rows() - this.topRow) + 2;
- }
-
- this.field_1.drawRect(r.x, r.y, r.width - 1, r.height - 1);
- }
-
- public synchronized void insertRow(int beforeRow) throws TypeNotSupported {
- Event e = new Event(this, 3, (Object)null);
- --beforeRow;
- e.y = beforeRow;
- if (!this.dataSource.handleEvent(e)) {
- this.dataSource.insertRow(beforeRow);
- }
-
- if (this.currSelectedCell != null && this.currSelectedCell.row() >= beforeRow) {
- this.currSelectedCell.setRow(this.currSelectedCell.row() + 1);
- }
-
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public int rowState(int row) {
- --row;
- return this.dataSource.rowState(row);
- }
-
- public void undeleteRow(int row) throws TypeNotSupported {
- --row;
- Event e = new Event(this, 7, (Object)null);
- e.y = row;
- if (!this.dataSource.handleEvent(e)) {
- this.dataSource.undeleteRow(row);
- }
-
- }
-
- public synchronized void deleteRow(int row) throws TypeNotSupported {
- --row;
- Event e = new Event(this, 4, (Object)null);
- e.y = row;
- if (!this.dataSource.handleEvent(e)) {
- this.dataSource.deleteRow(row);
- }
-
- if (this.currSelectedCell != null) {
- if (this.currSelectedCell.row() == row) {
- this.currSelectedCell = this.currCaptureCell = null;
- } else if (this.currSelectedCell.row() > row) {
- this.currSelectedCell.setRow(this.currSelectedCell.row() - 1);
- }
- }
-
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public synchronized int appendRow() throws TypeNotSupported {
- Event e = new Event(this, 5, (Object)null);
- int newRow;
- if (!this.dataSource.handleEvent(e)) {
- newRow = this.dataSource.appendRow();
- } else {
- newRow = e.y;
- }
-
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- return newRow;
- }
-
- public void addCellFromDefault(TableCell cell) {
- TableCell c = cell.cloneCell();
- this.cells.addElement(c.row(), c.col(), c);
- if (this.currSelectedCell == cell) {
- this.currSelectedCell = c;
- }
-
- if (this.currCaptureCell == cell) {
- this.currCaptureCell = c;
- }
-
- }
-
- protected TableCell getDefaultCell(int row, int col) {
- Coordinate c = this.defaultCell.getCoordinates();
- this.defaultCell.reset();
- c.row = row;
- c.col = col;
- return this.defaultCell;
- }
-
- protected TableCell getCell(int row, int col) {
- return this.cells.contains(row, col) ? (TableCell)this.cells.elementAt(row, col) : this.getDefaultCell(row, col);
- }
-
- public void save() throws TypeNotSupported {
- this.dataSource.commitData();
- this.dataSource.save();
- }
-
- public void restart() {
- this.refresh();
- }
-
- public void refresh() {
- this.dataSource.refresh();
- this.redraw(true);
- }
-
- public void redraw(boolean repaint) {
- this.redraw();
- if (repaint) {
- ((Component)this).repaint();
- }
-
- }
-
- public void redraw() {
- Dimension d = ((Component)this).size();
- if (this.width != d.width || this.height != d.height) {
- this.field_0 = ((Component)this).createImage(this.width = d.width, this.height = d.height);
- if (this.field_0 == null) {
- return;
- }
-
- this.field_1 = this.field_0.getGraphics();
- }
-
- this.forceRedraw(false);
- }
-
- public synchronized void forceRedraw(boolean repaint) {
- if (this.field_1 != null) {
- this.field_1.setColor(((Component)this).getBackground());
- this.field_1.fillRect(0, 0, this.width, this.height);
- this.setTopRow();
- this.showScrollbars();
- int count = this.getNumberOfVisibleRows();
- this.drawHeadings(count);
- this.drawRows(count, this.topRow);
- this.drawTableBoundary();
- if (repaint) {
- ((Component)this).repaint();
- }
-
- }
- }
-
- void drawRows(int count, int cellRow) {
- int r = 0;
- MatrixEnumeration e = this.cells.elements();
- TableCell c = null;
- int cols = this.getNumberOfCols();
- int currRow = -1;
- int currCol = -1;
- if (cellRow > 0) {
- if (cellRow >= this.cells.rows()) {
- e = null;
- } else {
- c = (TableCell)e.advanceTo(cellRow);
- }
- }
-
- while(count-- > 0) {
- for(int col = this.leftCol - 1; col < cols; ++col) {
- this.getColumnWidth(col);
-
- while(e != null && (c == null || e.currCol() < col && e.currRow() <= cellRow) && e.hasMoreElements()) {
- c = (TableCell)e.nextElement();
- currRow = e.currRow();
- currCol = e.currCol();
- if (currRow <= cellRow && currCol < col) {
- c = null;
- }
- }
-
- if (currRow == cellRow && currCol == col) {
- this.hints.setHints(c);
- c.drawCell(this.field_1, this.hints);
- c = null;
- } else if (this.currSelectedCell != null && this.currSelectedCell.row() == cellRow && this.currSelectedCell.col() == col) {
- this.hints.setHints(this.currSelectedCell);
- this.currSelectedCell.drawCell(this.field_1, this.hints);
- } else {
- TableCell defCell = this.getDefaultCell(cellRow, col);
- this.hints.setHints(defCell);
- defCell.drawCell(this.field_1, this.hints);
- }
- }
-
- ++cellRow;
- ++r;
- }
-
- if (this.currSelectedCell != null && this.currSelectedCell.isCellTypeEditable()) {
- this.frameCurrentCells();
- }
-
- }
-
- void frameCurrentCells() {
- if (this.currSelectedCell != null) {
- Rectangle r = this.getCellBounds(this.currSelectedCell);
- if (r.x < this.rowHeadingWidth || r.y < this.headingHeight + 2) {
- return;
- }
-
- this.field_1.setColor(Color.black);
- this.field_1.drawRect(r.x - 1, r.y - 1, r.width + 1, r.height + 1);
- this.field_1.drawRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3);
- }
-
- }
-
- int[] getColStartPositions() {
- return this.splitters;
- }
-
- public void handleException(int row, int col, Exception ex) {
- if (this.eventHandler != null) {
- this.eventHandler.handleException(new Coordinate(row, col), ex);
- }
-
- }
-
- public void undoRow(int row) throws TypeNotSupported {
- --row;
- this.dataSource.undoRow(row);
- }
-
- public void undoCurrentCell() {
- this.dataSource.rollbackCurrentData();
- if (this.currSelectedCell != null) {
- this.redrawCell(this.currSelectedCell.row(), this.currSelectedCell.col());
- }
-
- }
-
- public boolean generateEvent(Event e, int id, TableCell cell) {
- Object oldTarget = e.target;
- int oldId = e.id;
- Object oldArg = e.arg;
- boolean handled = false;
- e.id = id;
- e.target = this;
- e.arg = cell;
- handled = this.dispatchCellEvent(e);
- if (!this.dataSource.handleEvent(e)) {
- handled |= ((Component)this).postEvent(e);
- }
-
- e.target = oldTarget;
- e.id = oldId;
- e.arg = oldArg;
- return handled;
- }
-
- boolean dispatchCellEvent(Event e) {
- if (this.eventHandler != null && e.arg instanceof TableCell) {
- TableCell cell = (TableCell)e.arg;
- if (this.rowHeadingCell(cell)) {
- return this.eventHandler.handleRowHeadingEvent(e, cell);
- } else if (cell.type() == 1) {
- return this.eventHandler.handleColHeadingEvent(e, cell);
- } else {
- return cell == this.cornerCell ? this.eventHandler.handleCornerCellEvent(e, cell) : this.eventHandler.handleCellEvent(e, cell);
- }
- } else {
- return false;
- }
- }
-
- boolean handleHeadingClick(Event e, int x, int y) {
- int[] colstart = this.getColStartPositions();
- int shiftLeft = colstart[this.leftCol - 1] - this.rowHeadingWidth;
- if (x <= this.rowHeadingWidth && this.rowHeadingHints.visible) {
- if (x < this.rowHeadingWidth + this.clickMargin && x > this.rowHeadingWidth - this.clickMargin) {
- this.dragColumn = 0;
- this.isDragging = true;
- this.mouseDrag(e, x, y);
- return true;
- } else {
- if (this.rowHeadingCell(this.currCaptureCell)) {
- this.currHeadingCell = null;
- }
-
- this.currCaptureCell = this.cornerCell;
- this.translate(e);
- return this.cornerCell.mouseEvent(e);
- }
- } else {
- for(int i = this.leftCol - 1; i < this.splitters.length; ++i) {
- if (x < colstart[i] + this.clickMargin - shiftLeft && x > colstart[i] - this.clickMargin - shiftLeft) {
- this.dragColumn = i;
- this.isDragging = true;
- this.mouseDrag(e, x, y);
- return true;
- }
- }
-
- TableCell cell = (TableCell)this.colHeadings.elementAt(0, this.columnClicked(x));
- if (cell == null) {
- return true;
- } else {
- if (this.rowHeadingCell(this.currCaptureCell)) {
- this.currHeadingCell = null;
- }
-
- this.currCaptureCell = cell;
- this.translate(e);
- return cell.mouseEvent(e);
- }
- }
- }
-
- boolean handleRowHeadingClick(Event e, int x, int y) {
- this.currHeadingCell = this.headingCell.cloneCell();
- Coordinate c = this.currHeadingCell.getCoordinates();
- c.row = this.cellRow(y);
- c.col = 0;
- if (!this.validRow(c.row)) {
- return true;
- } else {
- this.currCaptureCell = this.currHeadingCell;
- this.translate(e);
- return this.currHeadingCell.mouseEvent(e);
- }
- }
-
- boolean handleSuccessiveClick(Event e) {
- long clickSpeed = e.when - this.clickTime;
- TableCell cell = this.currCaptureCell != null ? this.currCaptureCell : this.currSelectedCell;
- boolean handled;
- if (cell == null) {
- handled = false;
- } else if (clickSpeed < 250L) {
- e.target = cell;
- e.id = 63;
- this.translate(e);
- handled = cell.actionEvent(e);
- } else {
- e.target = cell;
- this.translate(e);
- handled = cell.mouseEvent(e);
- }
-
- this.clickTime = e.when;
- return handled;
- }
-
- int cellRow(int y) {
- return (y - this.headingHeight - 2) / this.cellHeight + this.topRow;
- }
-
- int columnClicked(int x) {
- int shiftLeft = this.splitters[this.leftCol - 1] - this.rowHeadingWidth;
-
- for(int i = 0; i < this.getNumberOfCols() - 1; ++i) {
- if (x < this.splitters[i + 1] - shiftLeft) {
- return i;
- }
- }
-
- return x < this.rowHeadingWidth ? -1 : this.getNumberOfCols() - 1;
- }
-
- void sendFocusEvents(TableCell lost, TableCell get) {
- Event e = new Event(lost, 1005, (Object)null);
- int oldRow = -1;
- if (this.currSelectedCell != null) {
- oldRow = this.currSelectedCell.row();
- }
-
- if (lost != null) {
- if (!lost.canLoseFocus()) {
- return;
- }
-
- this.currSelectedCell = get;
- lost.focusEvent(e);
- this.lostCapture();
- }
-
- try {
- if (oldRow != get.row()) {
- this.dataSource.setCurrentRow(get.row());
- }
- } catch (TypeNotSupported ex) {
- this.handleException(get.row(), get.col(), ex);
- }
-
- this.currSelectedCell = get;
- e.target = get;
- e.id = 1004;
- get.focusEvent(e);
- this.changeSelection(get.row(), get.col(), 0);
- this.clickTime = 0L;
- }
-
- public boolean mouseExit(Event e, int x, int y) {
- this.frame().setCursor(0);
- return true;
- }
-
- public boolean mouseDown(Event e, int x, int y) {
- if (e.target != this.vsb && e.target != this.hsb) {
- Rectangle r = new Rectangle();
- r = this.getTableBounds(r);
- if (!r.inside(x, y)) {
- return false;
- } else if (y < this.headingHeight + 1) {
- return this.handleHeadingClick(e, x, y);
- } else if (x < this.rowHeadingWidth && this.rowHeadingHints.visible) {
- return this.handleRowHeadingClick(e, x, y);
- } else if (x > this.width) {
- return true;
- } else {
- int row = this.cellRow(y);
- int col = this.columnClicked(x);
- TableCell newSelection = null;
- if (this.currSelectedCell != null && row == this.currSelectedCell.row() && col == this.currSelectedCell.col()) {
- this.handleSuccessiveClick(e);
- } else {
- if (!this.cells.contains(row, col)) {
- if (!this.validRow(row)) {
- return true;
- }
-
- newSelection = this.getDefaultCell(row, col).cloneCell();
- newSelection.setDefaultFlag();
- } else {
- newSelection = (TableCell)this.cells.elementAt(row, col);
- }
-
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- if (this.cellHasCapture()) {
- this.translate(e);
- return this.currCaptureCell.mouseEvent(e);
- }
- }
-
- return false;
- }
- } else {
- return false;
- }
- }
-
- public boolean validRow(int row) {
- if (row < 0) {
- return false;
- } else if (this.cells.rows() - 1 > row) {
- return true;
- } else {
- try {
- this.dataSource.validDataRowRange(row, row);
- return true;
- } catch (DataNotAvailable var2) {
- return false;
- }
- }
- }
-
- public boolean validCol(int col) {
- return col >= 0 && col < this.getNumberOfCols();
- }
-
- public boolean mouseDrag(Event e, int x, int y) {
- if (this.isDragging) {
- this.handleColDrag(x);
- return true;
- } else if (this.cellHasCapture()) {
- this.translate(e);
- return this.currCaptureCell.mouseEvent(e);
- } else {
- return false;
- }
- }
-
- boolean captureByHeading() {
- if (this.currCaptureCell == null) {
- return false;
- } else {
- Coordinate c = this.currCaptureCell.getCoordinates();
- return this.colHeadings.contains(c.row, c.col, this.currCaptureCell) || this.cornerCell == this.currCaptureCell;
- }
- }
-
- boolean captureByRowHeading() {
- if (this.currCaptureCell == null) {
- return false;
- } else {
- return this.rowHeadingCell(this.currCaptureCell) || this.cornerCell == this.currCaptureCell;
- }
- }
-
- Event translate(Event e) {
- TableCell cell = this.currCaptureCell != null ? this.currCaptureCell : this.currSelectedCell;
- int row = cell.getCoordinates().row;
- int col = cell.getCoordinates().col;
- int currY = (row - this.topRow) * this.cellHeight + this.headingHeight + 2;
- int currX = this.splitters[col] - this.splitters[this.leftCol - 1];
- if (!this.captureByRowHeading()) {
- e.x -= currX + this.rowHeadingWidth;
- }
-
- if (!this.captureByHeading()) {
- e.y -= currY;
- }
-
- return e;
- }
-
- void handleColDrag(int x) {
- int shiftLeft = this.splitters[this.leftCol - 1] + this.rowHeadingWidth;
- if (this.dragColumn == 0) {
- this.rowHeadingWidth = x;
- } else if (x < this.splitters[this.dragColumn - 1] - shiftLeft) {
- x = this.splitters[this.dragColumn - 1] - shiftLeft;
- }
-
- this.field_1.setColor(((Component)this).getBackground());
- this.field_1.setXORMode(Color.black);
- this.field_1.drawLine(this.xDragLast, 0, this.xDragLast, ((Component)this).size().height);
- this.field_1.drawLine(x, 0, x, ((Component)this).size().height);
- this.field_1.setColor(Color.black);
- this.field_1.setPaintMode();
- this.xDragLast = x;
- ((Component)this).repaint();
- }
-
- public synchronized void resizeColumn(int col, int rightSide) {
- int diff = rightSide - this.splitters[col] + this.splitters[this.leftCol - 1];
- int len = this.splitters.length;
- this.splitters[col] = rightSide + this.splitters[this.leftCol - 1];
-
- for(int i = col + 1; i < len; ++i) {
- int[] var10000 = this.splitters;
- var10000[i] += diff;
- }
-
- this.redraw(true);
- }
-
- public boolean mouseUp(Event e, int x, int y) {
- if (this.isDragging) {
- this.field_1.setColor(((Component)this).getBackground());
- this.field_1.setXORMode(Color.black);
- this.field_1.drawLine(this.xDragLast, 0, this.xDragLast, ((Component)this).size().height);
- this.field_1.setColor(Color.black);
- this.field_1.setPaintMode();
- if (this.dragColumn == 0) {
- this.redraw(true);
- } else {
- this.resizeColumn(this.dragColumn, this.xDragLast - this.rowHeadingWidth);
- }
-
- this.xDragLast = -1;
- this.isDragging = false;
- return true;
- } else if (this.cellHasCapture()) {
- this.translate(e);
- return this.currCaptureCell.mouseEvent(e);
- } else {
- return false;
- }
- }
-
- public boolean mouseMove(Event ev, int x, int y) {
- boolean isCloseEnough = false;
- int shiftLeft = this.splitters[this.leftCol - 1] - this.rowHeadingWidth;
- if (y >= this.headingHeight || !(((Container)this).locate(x, y) instanceof Scrollbar) || !this.vsb.isVisible()) {
- if (this.rowHeadingHints.visible && x < this.rowHeadingWidth + this.clickMargin && y < this.headingHeight) {
- if (x < this.rowHeadingWidth + this.clickMargin && x > this.rowHeadingWidth - this.clickMargin) {
- isCloseEnough = true;
- }
- } else if (y < this.headingHeight) {
- for(int i = 1; i < this.splitters.length; ++i) {
- if (x < this.splitters[i] + this.clickMargin - shiftLeft && x > this.splitters[i] - this.clickMargin - shiftLeft) {
- isCloseEnough = true;
- }
- }
- }
- }
-
- this.currentCursor = isCloseEnough ? 10 : 0;
- if (this.currentCursor != this.frame().getCursorType()) {
- this.frame().setCursor(this.currentCursor);
- }
-
- return false;
- }
-
- public boolean keyUp(Event e, int key) {
- if (this.currSelectedCell == null) {
- int row = this.topRow;
- int col = 0;
- } else {
- int row = this.currSelectedCell.row();
- int col = this.currSelectedCell.col();
- }
-
- if (this.currSelectedCell != null) {
- e.target = this.currSelectedCell;
- return this.currSelectedCell.keyEvent(e);
- } else {
- return false;
- }
- }
-
- public boolean lostFocus(Event e, Object o) {
- if (this.tabbed) {
- ((Component)this).requestFocus();
- this.tabbed = false;
- } else {
- if (this.currSelectedCell != null) {
- e.target = this.currSelectedCell;
- e.target = this;
- this.currSelectedCell.deactivateCursor();
- }
-
- this.lostCapture();
- }
-
- return false;
- }
-
- public boolean gotFocus(Event e, Object o) {
- if (this.currSelectedCell != null) {
- this.currSelectedCell.activateCursor();
- }
-
- return false;
- }
-
- TableCell getUniqueCell(int row, int col) {
- if (!this.cells.contains(row, col)) {
- TableCell cell = this.getDefaultCell(row, col).cloneCell();
- cell.setDefaultFlag();
- return cell;
- } else {
- return (TableCell)this.cells.elementAt(row, col);
- }
- }
-
- public boolean keyDown(Event e, int key) {
- boolean changed = false;
- if (this.eventHandler != null && this.isToolbarComponent(e.target)) {
- return this.eventHandler.handleToolbarEvent(e);
- } else {
- int row;
- int col;
- if (this.currSelectedCell == null) {
- row = this.topRow;
- col = 0;
- } else {
- row = this.currSelectedCell.row();
- col = this.currSelectedCell.col();
- }
-
- int dataRows = -1;
-
- try {
- dataRows = this.dataSource.validDataRowRange(0, row + 2);
- } catch (DataNotAvailable var8) {
- }
-
- switch (key) {
- case 9:
- this.tabbed = true;
- if (e.shiftDown()) {
- if (col > 0) {
- ((Component)this).requestFocus();
- TableCell newSelection = this.getUniqueCell(row, col - 1);
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- }
- } else if (col < this.getNumberOfCols() - 1) {
- ((Component)this).requestFocus();
- TableCell newSelection = this.getUniqueCell(row, col + 1);
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- }
- break;
- case 10:
- case 1005:
- if (this.currSelectedCell == null) {
- return false;
- }
-
- if (!this.currSelectedCell.loseFocusOnArrow()) {
- e.target = this.currSelectedCell;
- return this.currSelectedCell.keyEvent(e);
- }
-
- if (row < this.cells.rows() - 1 || row < dataRows) {
- TableCell newSelection = this.getUniqueCell(row + 1, col);
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- }
- break;
- case 1001:
- if (this.currSelectedCell == null || this.currSelectedCell.loseFocusOnArrow()) {
- this.setCurrentCell(this.currSelectedCell.row() + 1, this.getNumberOfCols());
- return true;
- }
- case 1000:
- if (this.currSelectedCell == null || this.currSelectedCell.loseFocusOnArrow()) {
- this.setCurrentCell(this.currSelectedCell.row() + 1, 1);
- return true;
- }
- default:
- if (this.currSelectedCell != null) {
- e.target = this.currSelectedCell;
- return this.currSelectedCell.keyEvent(e);
- }
- break;
- case 1002:
- this.scrollPageUp();
- changed = true;
- break;
- case 1003:
- this.scrollPageDown();
- changed = true;
- break;
- case 1004:
- if (this.currSelectedCell == null) {
- return false;
- }
-
- if (!this.currSelectedCell.loseFocusOnArrow()) {
- e.target = this.currSelectedCell;
- return this.currSelectedCell.keyEvent(e);
- }
-
- if (row > 0) {
- TableCell newSelection = this.getUniqueCell(row - 1, col);
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- }
- break;
- case 1006:
- if (this.currSelectedCell == null) {
- return false;
- }
-
- if (!this.currSelectedCell.loseFocusOnArrow()) {
- e.target = this.currSelectedCell;
- return this.currSelectedCell.keyEvent(e);
- }
-
- if (col > 0) {
- TableCell newSelection = this.getUniqueCell(row, col - 1);
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- }
- break;
- case 1007:
- if (this.currSelectedCell == null) {
- return false;
- }
-
- if (!this.currSelectedCell.loseFocusOnArrow()) {
- e.target = this.currSelectedCell;
- return this.currSelectedCell.keyEvent(e);
- }
-
- if (col < this.getNumberOfCols() - 1) {
- TableCell newSelection = this.getUniqueCell(row, col + 1);
- this.sendFocusEvents(this.currSelectedCell, newSelection);
- }
- }
-
- if (changed) {
- this.redraw(true);
- }
-
- return false;
- }
- }
-
- public boolean handleEvent(Event e) {
- if (this.isToolbarComponent(e.target)) {
- if (e.target == this.gotoButton) {
- e.arg = this.gotoTextField.getText();
- }
-
- return this.eventHandler.handleToolbarEvent(e);
- } else {
- if (e.target instanceof Scrollbar && e.id == 605) {
- Date d = new Date();
- e.when = d.getTime();
- if (e.when - this.scrollbarTimer < 300L) {
- return false;
- }
-
- this.scrollbarTimer = e.when;
- }
-
- if (e.target == this.vsb && e.arg != null) {
- switch (e.id) {
- case 601:
- this.scrollLineUp();
- break;
- case 602:
- this.scrollLineDown();
- break;
- case 603:
- this.scrollPageUp();
- break;
- case 604:
- this.scrollPageDown();
- break;
- case 605:
- this.scrollUpDownAbsolute(this.vsb.getValue());
- }
- }
-
- if (e.target == this.hsb && e.arg != null && this.leftCol != this.hsb.getValue()) {
- this.hsbPosition = this.leftCol = this.hsb.getValue();
- this.redraw();
- ((Component)this).getGraphics().drawImage(this.field_0, 0, 0, this);
- }
-
- if (e.target instanceof Scrollbar) {
- ((Component)this).requestFocus();
- }
-
- return super.handleEvent(e);
- }
- }
-
- public void gotoRow(int row) {
- if (row < this.topRow || row > this.topRow + this.getPageSize().height - 1) {
- this.scrollUpDownAbsolute(row);
- }
-
- }
-
- public synchronized void scrollUpTo(int newTop) {
- newTop = Math.max(0, newTop);
- if (newTop != this.topRow) {
- this.topRow = newTop;
- this.vsbPosition = this.topRow;
- this.vsb.setValue(this.vsbPosition);
- this.redraw(true);
- }
-
- }
-
- public void scrollUpDownAbsolute(int row) {
- if (row < this.topRow) {
- this.scrollUpTo(row);
- } else {
- this.scrollDownTo(row);
- }
- }
-
- public void scrollLineUp() {
- this.scrollUpTo(this.topRow - 1);
- }
-
- public void scrollPageUp() {
- this.scrollUpTo(this.topRow - this.getPageSize().height + 1);
- }
-
- public synchronized void scrollDownTo(int nextTop) {
- int lastRow = this.cells.rows() - 1;
-
- try {
- lastRow = Math.max(lastRow, this.dataSource.validDataRowRange(0, nextTop));
- } catch (DataNotAvailable var3) {
- }
-
- nextTop = Math.min(nextTop, lastRow);
- if (nextTop >= this.topRow) {
- this.vsbPosition = this.topRow = nextTop;
- this.vsb.setValue(this.vsbPosition);
- this.redraw(true);
- }
-
- }
-
- public void scrollLineDown() {
- this.scrollDownTo(this.topRow + 1);
- }
-
- public void scrollPageDown() {
- this.scrollDownTo(this.topRow + this.getPageSize().height - 1);
- }
-
- public synchronized void makeCellVisible(int row, int col) {
- boolean changed = false;
- int rc = this.cells.rows();
-
- try {
- rc = Math.max(rc, this.dataSource.validDataRowRange(0, row + 1) + 1);
- } catch (DataNotAvailable var5) {
- }
-
- row = Math.min(rc - 1, row);
- row = Math.max(0, row);
- col = Math.min(col, this.splitters.length);
- col = Math.max(0, col);
- if (row < this.topRow) {
- this.topRow = row;
- this.vsbPosition = this.topRow;
- this.vsb.setValue(this.vsbPosition);
- changed = true;
- }
-
- if (row > this.topRow + this.getPageSize().height - 1) {
- this.topRow = row - this.getPageSize().height + 1;
- this.vsbPosition = this.topRow;
- this.vsb.setValue(this.vsbPosition);
- changed = true;
- }
-
- ++col;
- if (col < this.leftCol) {
- this.leftCol = col < 1 ? 1 : col;
- this.hsbPosition = this.leftCol;
- this.hsb.setValue(this.hsbPosition);
- changed = true;
- }
-
- if (col > this.leftCol + this.getPageSize().width - 1) {
- this.hsbPosition = this.leftCol = col - this.getPageSize().width + 1;
- this.hsb.setValue(this.hsbPosition);
- changed = true;
- }
-
- if (changed) {
- this.redraw(true);
- }
-
- }
-
- void changeSelection(int row, int col, int modifiers) {
- switch (modifiers) {
- case 1:
- case 2:
- default:
- this.makeCellVisible(row, col);
- }
- }
-
- boolean postEvent(int id, int num) {
- Event e = new Event(this, id, new Integer(num));
- return ((Component)this).postEvent(e);
- }
-
- Dimension getPageSize() {
- Dimension d = ((Component)this).size();
-
- int i;
- for(i = this.leftCol; i < this.splitters.length && this.splitters[i] - this.splitters[this.leftCol - 1] <= d.width; ++i) {
- }
-
- d.width = i - this.leftCol;
- d.height -= this.bottomPanel.size().height;
- d.height = (d.height - this.headingHeight) / this.cellHeight;
- return d;
- }
-
- void drawHeadings(int numRowsToDraw) {
- MatrixEnumeration e = this.colHeadings.elements();
- TableCell c = null;
- int cols = this.getNumberOfCols();
-
- while(e.hasMoreElements() || c != null) {
- for(int col = this.leftCol - 1; col < cols; ++col) {
- this.getColumnWidth(col);
-
- while((c == null || e.currCol() < col) && e.hasMoreElements()) {
- c = (TableCell)e.nextElement();
- if (e.currCol() < col) {
- c = null;
- }
- }
-
- if (e.currCol() == col) {
- this.hints.setHints(c);
- c.drawCell(this.field_1, this.hints);
- c = null;
- }
-
- if (c != null) {
- c = null;
- }
- }
- }
-
- this.drawRowHeadings(numRowsToDraw);
- }
-
- synchronized void redrawColHeadingCell(int col) {
- if (col >= this.leftCol - 1 && col < this.getNumberOfCols()) {
- TableCell cell = (TableCell)this.colHeadings.elementAt(0, col);
- this.hints.setHints(cell);
- cell.drawCell(this.field_1, this.hints);
- }
- }
-
- synchronized void redrawRowHeadingCell(int row) {
- if (this.rowHeadingHints.visible && this.validRow(row)) {
- if (this.rowHeadingCell(this.currCaptureCell) && this.currCaptureCell.row() == row) {
- this.hints.setHints(this.currHeadingCell);
- this.currHeadingCell.drawCell(this.field_1, this.hints);
- } else {
- TableCell cell = this.headingCell.cloneCell();
- cell.setRow(row);
- this.hints.setHints(cell);
- cell.drawCell(this.field_1, this.hints);
- }
- }
- }
-
- void drawRowHeadings(int count) {
- if (this.rowHeadingHints.visible) {
- TableCell cell = this.headingCell.cloneCell();
- cell.getCoordinates();
-
- for(int i = 0; i < count; ++i) {
- cell.setRow(i + this.topRow);
- this.hints.setHints(cell);
- cell.drawCell(this.field_1, this.hints);
- }
-
- if (this.rowHeadingCell(this.currCaptureCell)) {
- this.hints.setHints(this.currHeadingCell);
- this.currHeadingCell.drawCell(this.field_1, this.hints);
- }
-
- this.redrawCornerCell();
- }
- }
-
- synchronized void redrawCornerCell() {
- this.hints.setHints(this.cornerCell);
- this.cornerCell.drawCell(this.field_1, this.hints);
- }
-
- Frame frame() {
- Container c;
- for(c = this; !(c instanceof Frame); c = ((Component)c).getParent()) {
- }
-
- return (Frame)c;
- }
-
- public CellHints getCellHints(int row, int col) {
- ++row;
- ++col;
- return this.cellAttributes.contains(row, col) ? (CellHints)this.cellAttributes.elementAt(row, col) : null;
- }
-
- public CellHints getRowHints(int row) {
- ++row;
- return this.cellAttributes.contains(row, 0) ? (CellHints)this.cellAttributes.elementAt(row, 0) : null;
- }
-
- public CellHints getColHints(int col) {
- ++col;
- return (CellHints)this.cellAttributes.elementAt(0, col);
- }
-
- public CellHints getHeadingHints(int row, int col) {
- return (CellHints)this.headingAttributes.elementAt(row, col);
- }
-
- public CellHints getHintsForCell(TableCell c, int row, int col) {
- if (this.rowHeadingCell(c)) {
- return this.rowHeadingHints;
- } else if (c.type() == 1) {
- return this.getHeadingHints(row, col + 1);
- } else {
- CellHints h = this.getCellHints(row, col);
- if (h != null) {
- return h;
- } else {
- h = this.getRowHints(row);
- if (h != null) {
- return h;
- } else {
- h = this.getColHints(col);
- return h;
- }
- }
- }
- }
-
- public int getCellAlignment(TableCell c) {
- CellHints h = this.getHintsForCell(c, c.row(), c.col());
- return h.alignment();
- }
-
- public Color getCellFG(TableCell c) {
- CellHints h = this.getHintsForCell(c, c.row(), c.col());
- return h.foreground();
- }
-
- public Color getCellBG(TableCell c) {
- CellHints h = this.getHintsForCell(c, c.row(), c.col());
- return h.background();
- }
-
- boolean getCellEditable(TableCell c) {
- CellHints h = this.getHintsForCell(c, c.row(), c.col());
- return h.editable();
- }
-
- boolean getCellHighlighted(TableCell c) {
- int row = c.row() + 1;
- int col = c.col() + 1;
- if (c.type() == 1) {
- this.isColumnSelected(col);
- } else {
- if (c == this.cornerCell) {
- return this.isViewSelected();
- }
-
- if (this.rowHeadingCell(c)) {
- if (!this.isRowSelected(row) && !this.isCellSelected(row, col)) {
- return false;
- }
-
- return true;
- }
- }
-
- return this.isCellSelected(row, col);
- }
-
- Font getCellFont(TableCell c) {
- CellHints h = this.getHintsForCell(c, c.row(), c.col());
- return h.font();
- }
-
- boolean getCellVisibility(TableCell c) {
- if (this.rowHeadingCell(c)) {
- return this.rowHeadingHints.visible;
- } else if (c.type() == 1) {
- return this.getHeadingHints(c.row(), c.col() + 1).isVisible();
- } else {
- CellHints h = this.getCellHints(c.row(), c.col());
- if (h != null && !h.isVisible()) {
- return false;
- } else {
- h = this.getRowHints(c.row());
- if (h != null && !h.isVisible()) {
- return false;
- } else {
- h = this.getColHints(c.col());
- return h.isVisible();
- }
- }
- }
- }
-
- public boolean isRowSelected(int row) {
- return this.selected.get(this.tx4Sxn(row));
- }
-
- public boolean isCellSelected(int row, int col) {
- return this.selected.get(this.tx4Sxn(row, col));
- }
-
- public boolean isColumnSelected(int col) {
- return this.selected.get(col);
- }
-
- public boolean isViewSelected() {
- return this.selected.get(0);
- }
-
- public void toggleCell(int row, int col) {
- if (!this.isRowSelected(row)) {
- this.toggleBit(this.tx4Sxn(row, col));
- }
-
- }
-
- public Coordinate[] getSelectedCells() {
- Vector cells = new Vector();
- int cols = this.getNumberOfCols();
- int rows = this.sxnRows(cols);
-
- for(int row = 1; row < rows; ++row) {
- for(int col = 1; col < cols; ++col) {
- if (this.selected.get(this.tx4Sxn(row, col))) {
- cells.addElement(new Coordinate(row, col));
- }
- }
- }
-
- Coordinate[] sxn = new Coordinate[cells.size()];
- cells.copyInto(sxn);
- return sxn;
- }
-
- public int getFirstSelectedRow() {
- int cols = this.getNumberOfCols();
- int total = this.selected.size();
- int row = 1;
-
- for(int index = cols + 1; index < total; ++row) {
- if (this.selected.get(index)) {
- return row;
- }
-
- index += cols + 1;
- }
-
- return -1;
- }
-
- public int[] getSelectedRows() {
- int cols = this.getNumberOfCols();
- int total = this.selected.size();
- int[] srows = new int[this.dataSource.rows()];
- int row = 1;
- int next = 0;
-
- for(int index = cols + 1; index < total; ++row) {
- if (this.selected.get(index)) {
- srows[next++] = row;
- }
-
- index += cols + 1;
- }
-
- int[] sxn = new int[next];
- System.arraycopy(srows, 0, sxn, 0, next);
- return sxn;
- }
-
- public int[] getSelectedCols() {
- int cols = this.getNumberOfCols();
- int[] scols = new int[cols];
- int next = 0;
-
- for(int col = 1; col <= cols; ++col) {
- if (this.selected.get(col)) {
- scols[next - 1] = col;
- ++next;
- }
- }
-
- int[] sxn = new int[next];
- System.arraycopy(scols, 0, sxn, 0, next);
- return sxn;
- }
-
- public boolean isRowSet(int row) {
- return this.selected.get(this.tx4Sxn(row));
- }
-
- public synchronized void setRow(int row, boolean setTo) {
- int bit = this.tx4Sxn(row);
- int cols = this.getNumberOfCols();
-
- for(int i = 0; i <= cols; ++i) {
- if (setTo) {
- this.selected.set(bit + i);
- } else {
- this.selected.clear(bit + i);
- }
- }
-
- this.selectionMade = true;
- if (this.autoRedraw) {
- this.redrawRow(row);
- }
-
- }
-
- public synchronized void toggleRow(int row) {
- int bit = this.tx4Sxn(row);
- boolean set = this.selected.get(bit);
- int cols = this.getNumberOfCols();
-
- for(int i = 0; i <= cols; ++i) {
- if (set) {
- this.selected.clear(bit + i);
- } else {
- this.selected.set(bit + i);
- }
- }
-
- this.selectionMade = true;
- if (this.autoRedraw) {
- this.redrawRow(row);
- }
-
- }
-
- public synchronized void toggleCol(int col) {
- boolean set = this.selected.get(col);
- int cols = this.getNumberOfCols();
- int total = this.selected.size();
-
- for(int i = col; i <= total; i += cols + 1) {
- if (set) {
- this.selected.clear(i);
- } else {
- this.selected.set(i);
- }
- }
-
- this.selectionMade = true;
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public synchronized void toggleAll() {
- if (this.selected.get(0)) {
- this.clearAllSelections();
- } else {
- int total = this.selected.size();
-
- for(int i = 0; i < total; ++i) {
- this.selected.set(i);
- }
-
- this.selectionMade = true;
- }
-
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public synchronized void clearAllSelections() {
- if (this.selectionMade) {
- this.selectionBase = null;
- this.selectionLimit = null;
- this.selectionMade = false;
- this.selected.xor(this.selected);
- if (this.autoRedraw) {
- this.redraw(true);
- }
- }
-
- }
-
- public void setSelectionBase(int row, int col) {
- this.selectionBase = new Coordinate(row, col);
- }
-
- public boolean isSelectionBaseSet() {
- return this.selectionBase != null;
- }
-
- public boolean isRangeSelected() {
- return this.selectionLimit != null;
- }
-
- public void eraseRangeSelection() {
- this.setRange(false);
- }
-
- synchronized void setRange(boolean setTo) {
- if (this.selectionBase != null) {
- if (this.selectionLimit == null) {
- this.selectionLimit = this.selectionBase;
- }
-
- int topRow = Math.min(this.selectionBase.row, this.selectionLimit.row);
- Math.min(this.selectionBase.col, this.selectionLimit.col);
- int bottomRow = Math.max(this.selectionBase.row, this.selectionLimit.row);
- Math.max(this.selectionBase.col, this.selectionLimit.col);
- boolean auto = this.autoRedraw;
- this.autoRedraw = false;
- if (this.selectionBase.col == 0 && this.selectionLimit.col == 0) {
- for(int row = topRow; row <= bottomRow; ++row) {
- this.setRow(row, setTo);
- }
- }
-
- this.autoRedraw = auto;
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
- }
-
- public void clearRangeSelection() {
- this.eraseRangeSelection();
- this.selectionBase = null;
- this.selectionLimit = null;
- }
-
- public synchronized void selectRange(int limitRow, int limitCol) {
- if (this.selectionBase == null) {
- this.selectionBase = new Coordinate(limitRow, limitCol);
- }
-
- boolean auto = this.autoRedraw;
- this.autoRedraw = false;
- this.eraseRangeSelection();
- this.selectionLimit = new Coordinate(limitRow, limitCol);
- this.setRange(true);
- this.autoRedraw = auto;
- if (this.autoRedraw) {
- this.redraw(true);
- }
-
- }
-
- public void selectRange(int baseRow, int baseCol, int limitRow, int limitCol) {
- this.clearRangeSelection();
- this.selectionBase = new Coordinate(baseRow, baseCol);
- this.selectRange(limitRow, limitCol);
- }
-
- final void toggleBit(int bit) {
- this.selectionMade = true;
- if (this.selected.get(bit)) {
- this.selected.clear(bit);
- } else {
- this.selected.set(bit);
- }
- }
-
- final int tx4Sxn(int row, int col) {
- return this.tx4Sxn(row) + col;
- }
-
- final int tx4Sxn(int row) {
- int cols = this.getNumberOfCols();
- return (cols + 1) * row;
- }
-
- final int sxnRows(int cols) {
- return (int)Math.ceil((double)((float)this.selected.size() / ((float)cols + 1.0F)));
- }
- }
-